package org.agile2soft.nexoma.tapestry.model;

import java.util.ArrayList;
import java.util.List;

import org.agile2soft.nexoma.core.entity.Service;
import org.agile2soft.nexoma.core.entity.ServiceOption;
import org.agile2soft.nexoma.core.entity.ServicesGroup;

@SuppressWarnings("serial")
public class SessionContainer implements java.io.Serializable {

    private ServicesGroup currentGroup;
    private Service currentService;
    private ServiceOption currentOption;

    public ServicesGroup getCurrentGroup() {
        return currentGroup;
    }

    public void setCurrentGroup(ServicesGroup currentGroup) {
        this.currentGroup = currentGroup;
        this.currentService=null;
        this.currentOption=null;
    }

    public Service getCurrentService() {
        return currentService;
    }

    public void setCurrentService(Service currentService) {
        this.currentService = currentService;
        this.currentOption=null;
    }

    public ServiceOption getCurrentOption() {
        return currentOption;
    }

    public void setCurrentOption(ServiceOption currentOption) {
        this.currentOption = currentOption;
    }

    public void clearAll() {
        this.currentGroup = null;
        this.currentService = null;
        this.currentOption = null;
    }

    public List<Integer> getCurrentSelection() {
        List<Integer> selection = new ArrayList<Integer>();
        if ( currentGroup!=null ) {
            selection.add(currentGroup.getId());
        }
        if ( currentService!=null ) {
            selection.add(currentService.getId());
        }
        return selection;
    }


    public void clearGroup () {
        this.currentGroup = null;
    }

    public void clearService() {
        this.currentService = null;
    }

    public void clearOption() {
        this.currentOption = null;
    }
}
